<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    

<script>

// startsWith(val)判断字符串的开头是否为val，返回布尔值
// endsWith(val)判断字符串的结尾是否为val，返回布尔值

let str = '123ddfgtjytuwww';
console.log( str.startsWith('1') );// true
console.log( str.startsWith('123') );// true
console.log( str.startsWith('1a') );// false

console.log( str.endsWith('w') );// true
console.log( str.endsWith('www') );// true
console.log( str.endsWith('3w') );// false

</script>
</body>
</html>